function ModuleDialogAddTask(doc, container, width, height, user, date, options, data) {
  this._doc = doc;
  this._container = container;
  this._width = width;
  this._height = height;
  this._user = user;
  this._date = date;
  this._options = options;
  this._data = data;
  
  this._item = (options && options.object) ? options.object : null;
  this._popupBox = new ModulePopupBoxSimple();
  this._models = this._data['pz_model'];
  this._states = this._data['pz_model_state'];
  this._transitions = this._data['pz_model_transition'];
  
  this._createElements();
};

ModuleDialogAddTask.prototype._createElements = function() {
  var unique = MiscUtils.unique(), _self = this;

  this._gui = new DialogAddTask(this._doc, this._container, this._width, this._height, this._user, this._date, this._options, this._data)._gui;
  
  var pos = DOMUtils.findPos(this._gui.user);
  var pos1 = [pos[0]+200, pos[1]+100];
  MiscUtils.load(this._popupBox, pos1, ' Loading Data... ');
  
  this._loadData();
};

ModuleDialogAddTask.prototype._loadData = function() {
  this._users = null;
  this._retrieveUsers();
};

ModuleDialogAddTask.prototype._verifyData = function() {
  if (this._users) {
    this._updateElements();
  }
};

ModuleDialogAddTask.prototype._retrieveUsers = function() {
  var _self = this;
  new RequestUtils()._read('pz_user', null, 'd.type=\'' + Constant.USER_TYPE_DESIGNER + '\'', null, null, null, null, function(result, params) { _self._users = result.data;
                                                                                                     _self._verifyData.call(_self);
                                                                                                   }, null);
};

ModuleDialogAddTask.prototype._updateElements = function() {
  var _self = this;
  this._popupBox._close();
  
  PPublishUtils.clear(this._gui);
  this._item.model_id = 3;
  this._item.state_id = 18;
  this._item.wedding_date = 0;
  this._item.sent_date = 0;
  this._item.received_date = 0;
  this._item.backuped_date = 0;
  this._item.chosen_date = 0
  this._item.asstretouched_date = 0;
  this._item.checked_date = 0;
  this._item.adminretouched_date = 0;
  this._item.choosedesigner_date = 0
  this._item.retouched_date = 0;
  this._item.sorted_date = 0;
  this._item.prearrange_date = 0;
  this._item.authorarranged_date = 0;
  this._item.authorreceived_date = 0;
  this._item.published_date = 0;
  this._item.confirmpublished_date = 0;
  
  this._gui.branch.options[this._gui.branch.options.length] = new Option('-');
  for (var i = 0, il = Branch.array().length; i < il; i++) {
    var branch = Branch.array()[i];
    option = new Option(branch);
    this._gui.branch.options[this._gui.branch.options.length] = option;
    if (option.text == this._item.branch) {
      this._gui.branch.selectedIndex = this._gui.branch.options.length - 1;
    }
  }
  this._gui.branch.onchange = function() { _self._item.branch = this.options[this.selectedIndex].text; };
  
  this._gui.cusNumber.value = '';
  this._gui.cusNumber.onchange = function() { _self._item.customer_id = this.value };
  
  this._gui.deadline.value = '';
  this._gui.deadline.onclick = function() { var context = this;
                                            _self._changeDate.call(_self, this, SimpleDate.fromStamp(_self._item.deadline), function(sd) { _self._item.deadline = SimpleDate.toStamp(sd); context.focus(); }, false);
                                            return false;
                                          };
  
  this._item.custom_assigner_id = this._user.id;
  
  for (var i = 0, il = this._users.length; i < il; i++) {
    var u = this._users[i];
    option = new Option(u.name + '(' + u.type + ')');
    option._u = u;
    this._gui.user.options[this._gui.user.options.length] = option;
    if (option._u.id == _self._item.assignee_id) {
      this._gui.user.selectedIndex = this._gui.user.options.length - 1;
    }
  }
  
  this._item.custom_assignee_id = this._gui.user.options[this._gui.user.selectedIndex]._u.id;
  //this._item.photographer_old_id = (this._gui.user.options[this._gui.user.selectedIndex]._u.type == Constant.USER_TYPE_PHOTOGRAPHER) ? this._gui.user.options[this._gui.user.selectedIndex]._u.photographer_old_id : 0;
  //this._item.designer_id = (this._gui.user.options[this._gui.user.selectedIndex]._u.type == Constant.USER_TYPE_DESIGNER) ? this._gui.user.options[this._gui.user.selectedIndex]._u.id : 0;
  this._gui.user.onchange = function() { _self._item.custom_assignee_id = this.options[this.selectedIndex]._u.id; 
                                         //_self._item.photographer_old_id = (this.options[this.selectedIndex]._u.type == Constant.USER_TYPE_PHOTOGRAPHER) ? this.options[this.selectedIndex]._u.photographer_old_id : 0;
                                         //_self._item.designer_id = (this.options[this.selectedIndex]._u.type == Constant.USER_TYPE_DESIGNER) ? this.options[this.selectedIndex]._u.id : 0;
                                       };
  
  this._gui.content.value = '';
  this._gui.content.onchange = function() { _self._item.custom_task = this.value; };
};

ModuleDialogAddTask.prototype._changeDate = function(label, currentDate, onChangeFunc, showTime) {
  var _self = this;
  this._wContainer = document.createElement('div');
  this._wContainer.style.left = DOMUtils.findPos(label)[0] + 'px';
  this._wContainer.style.top = DOMUtils.findPos(label)[1] + 'px';
  this._popupBox._open(this._wContainer, { pos: DOMUtils.findPos(label) });
  
  var ds = new DateSelect(currentDate, null, { container: this._wContainer, showTime: showTime });
  ds._selectFunc = function(sd) { _self._selectDate.call(_self, sd, label, onChangeFunc, showTime); };
};

ModuleDialogAddTask.prototype._selectDate = function(sd, label, onChangeFunc, showTime) {
  
  onChangeFunc(sd);
  this._showDate(sd, label, showTime);
  this._popupBox._close();
};

ModuleDialogAddTask.prototype._showDate = function(sd, label, showTime) {
  if (sd) { 
    label.value = SimpleDate.format(sd, showTime);
  } else {
    label.value = '';
  }
};